import { ZAN_INCRE, ZAN_DECRE } from "../contants";
//声明 reducer 函数
let zanReducer = (zan=0, action) => {
  //根据 action.type 对 state 进行更新
  switch (action.type){
    case ZAN_INCRE:
      return zan + action.payload;
    case ZAN_DECRE:
      return zan - action.payload;
    default:
      return zan;
  }
};  

//暴露
export default zanReducer;

//声明 action creator
export let increAction = payload => ({type:ZAN_INCRE, payload});

export let decreAction = payload => ({type:ZAN_DECRE, payload});